package com.spring.learn.springboot.learn02;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * Created by bgt on 2018/4/30.
 * //获取上下文的几种方式
 */
@Component
public class UserService implements ApplicationContextAware {
    private ApplicationContext applicationContext;

    public void show(){
        System.out.println(this.getClass().getName()+"-----"+applicationContext.getDisplayName());
    }
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext=applicationContext;
    }
}
